package com.atguigu.client;

import java.sql.*;

/**
 * Created by Smexy on 2023/1/11
 *
 *  功能多，加载的jar包多，胖。不依赖第三方！
 *  hive cli-----> sql ---->parse ----> job ----> 提交到yarn ----->返回结果
 *
 *  ----------------------
 *
 *  功能少，加载的jar包少，瘦，先启动服务，才能工作
 *  客户端
 *  beeline|idea-----> sql ----->服务端(hiveserver2)
 *
 *  服务端
 *  hiveserver2---->parse ----> job ----> 提交到yarn ----->返回结果到客户端
 *
 *
 */
public class FatClient
{

    public static void main(String[] args) throws SQLException {

        // 1.添加链接
        String url = "jdbc:phoenix:hadoop104:2181";

        // 2.获取连接
        Connection connection = DriverManager.getConnection(url);

        // 3.编译SQL语句
        PreparedStatement preparedStatement = connection.prepareStatement("select * from student");

        // 4.执行语句
        ResultSet resultSet = preparedStatement.executeQuery();

        // 5.输出结果
        while (resultSet.next()){
            System.out.println(resultSet.getString(1) + ":" + resultSet.getString(2) + ":" + resultSet.getString(3));
        }

        // 6.关闭资源
        connection.close();

    }



}
